from pyflink.datastream import StreamExecutionEnvironment, FilterFunction

env = StreamExecutionEnvironment.get_execution_environment()


env.set_parallelism(1)

students_ds = env.read_text_file('../../data/students.txt')
# 1、lambda表达式
# students_ds.filter(lambda line: line.split(',')[3] == '男').print()



# 2、函数
def filter_func(line):
    split = line.split(',')
    return split[3] == '男'

# students_ds.filter(filter_func).print()



# 3、使用类的方式

class FilterClass(FilterFunction):

    def filter(self, line):
        split = line.split(',')
        return split[3] == '男'

students_ds.filter(FilterClass()).print()
env.execute()